//
//  DSSHTaskQiangSettingVC.m
//  DSSH
//
//  Created by lcy on 16/4/14.
//  Copyright © 2016年 lcy. All rights reserved.
//

#import "DSSHTaskQiangSettingVC.h"
#import "DSSHTaskQiangSettingVC.h"
#import "UIView+Round.h"
#import "QiangTaskDetailCell2.h"
@interface DSSHTaskQiangSettingVC ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView*settingTableView;
@end

@implementation DSSHTaskQiangSettingVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupViewAndData];
    // Do any additional setup after loading the view.
}
-(void)setupViewAndData
{
    self.title = @"抢单设置";
    self.automaticallyAdjustsScrollViewInsets = NO;
    UIBarButtonItem * backBarBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"fanhui"] style:UIBarButtonItemStylePlain target:self action:@selector(backBarBtnClick)];
    self.navigationItem.leftBarButtonItem = backBarBtn;
    
    //添加详情表
    self.settingTableView =[[ UITableView alloc]initWithFrame:CGRectMake(5, 69, ZYAppWidth-10, ZYAppHeight-69) style:UITableViewStylePlain];
    self.settingTableView.delegate = self;
    self.settingTableView.dataSource = self;
    [self.settingTableView getRoundView:5];
    self.settingTableView.layer.borderWidth = 1;
    self.settingTableView.layer.borderColor = [[UIColor grayColor]CGColor];
    
    [self.view addSubview:self.settingTableView];
    
    
}

-(void)backBarBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.00001;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ( indexPath.row == 1)
    {
        QiangTaskDetailCell2 * cell = [tableView cellForRowAtIndexPath:indexPath];
        if (!cell)
        {
            cell = [[NSBundle mainBundle]loadNibNamed:@"QiangTaskDetailCell2" owner:nil options:nil][0];
        }
        return cell;
    }else
    {
        UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
        if (!cell)
        {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellID"];
        }
        if (indexPath.row == 0)
        {
            cell.contentView.backgroundColor = COLOR_NAVIGATE_BAR;
            cell.textLabel.text = @"项目名称：未来之光";
            cell.textLabel.font = FONT(16);
            cell.textLabel.textAlignment = NSTextAlignmentCenter;
            cell.textLabel.textColor = [UIColor whiteColor];
        }
        if (indexPath.row == 2)
        {
            cell.textLabel.text = @"抢单设置";
            cell.textLabel.font = FONT(14);
        }
        if (indexPath.row == 3)
        {
            UILabel * qiangLabel = [UILabel new];
            qiangLabel.text = @"抢单价格：";
            qiangLabel.font = FONT(13);
            [cell.contentView addSubview:qiangLabel];
            
            UILabel * yuanLabel = [UILabel new];
            yuanLabel.text = @"元";
            yuanLabel.font = FONT(13);
            [cell.contentView addSubview:yuanLabel];
            
            UILabel * explainLabel = [UILabel new];
            explainLabel.text = @"抢单说明：";
            explainLabel.font = FONT(13);
            [cell.contentView addSubview:explainLabel];
            
            UITextField * moneyTF = [[UITextField alloc]init];
            moneyTF.borderStyle = UITextBorderStyleRoundedRect;
            [cell.contentView addSubview:moneyTF];
            
            UITextView * explainTV = [[UITextView alloc]init];
            [explainTV getRoundView:5];
            explainTV.layer.borderWidth = 1;
            explainTV.layer.borderColor = [[UIColor grayColor]CGColor];
            [cell.contentView addSubview:explainTV];
            
            UIButton * cancelBtn = [UIButton new];
            [cancelBtn getRoundView:5];
            [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
            cancelBtn.titleLabel.font = FONT(13);
            [cancelBtn setBackgroundColor:COLOR_NAVIGATE_BAR];
            [cell.contentView addSubview:cancelBtn];
            
            UIButton * sendBtn = [UIButton new];
            [sendBtn getRoundView:5];
            [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
            sendBtn.titleLabel.font = FONT(13);
            [sendBtn setBackgroundColor:COLOR_NAVIGATE_BAR];
            [cell.contentView addSubview:sendBtn];
            
            
            [qiangLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(cell.contentView.mas_left).with.offset(30*WIDTH_SCALE);
                make.top.equalTo(cell.contentView.mas_top).with.offset(15*HIGHT_SCALE);
                make.size.mas_equalTo(CGSizeMake(75*WIDTH_SCALE, 30*HIGHT_SCALE));
            }];
            [moneyTF mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(qiangLabel.mas_right).with.offset(5*WIDTH_SCALE);
                make.top.equalTo(cell.contentView.mas_top).with.offset(15*HIGHT_SCALE);
                make.size.mas_equalTo(CGSizeMake(100*WIDTH_SCALE, 30*HIGHT_SCALE));
            }];
            [yuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(moneyTF.mas_right).with.offset(5*WIDTH_SCALE);
                make.top.equalTo(cell.contentView.mas_top).with.offset(15*HIGHT_SCALE);
                make.size.mas_equalTo(CGSizeMake(20*WIDTH_SCALE, 30*HIGHT_SCALE));
            }];
            
            [explainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(cell.contentView.mas_left).with.offset(30*WIDTH_SCALE);
                make.top.equalTo(qiangLabel.mas_bottom).with.offset(10*HIGHT_SCALE);
                make.size.mas_equalTo(CGSizeMake(75*WIDTH_SCALE, 30*HIGHT_SCALE));
            }];
            [explainTV mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(explainLabel.mas_right).with.offset(5*WIDTH_SCALE);
                make.right.equalTo(cell.contentView.mas_right).with.offset(-10*WIDTH_SCALE);
                make.top.equalTo(qiangLabel.mas_bottom).with.offset(10*HIGHT_SCALE);
                make.height.mas_equalTo(100*HIGHT_SCALE);
            }];
            
            [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(cell.contentView.mas_left).with.offset(10*WIDTH_SCALE);
                make.top.equalTo(explainTV.mas_bottom).with.offset(15*HIGHT_SCALE);
                make.size.mas_equalTo(CGSizeMake(150*WIDTH_SCALE, 35*HIGHT_SCALE));
            }];
            [sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(cell.contentView.mas_right).with.offset(-10*WIDTH_SCALE);
                make.top.equalTo(explainTV.mas_bottom).with.offset(15*HIGHT_SCALE);
                make.size.mas_equalTo(CGSizeMake(150*WIDTH_SCALE, 35*HIGHT_SCALE));
            }];

        }
        
        return cell;
        
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 1)
    {
        return 270;
    }
    if (indexPath.row == 3)
    {
        return 170*HIGHT_SCALE;
    }
    else
    {
        return 44;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
